<?php
	ob_end_clean();
	ob_start();
?>

<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
	</head>
<body>

<?php
	require_once( '../system/smarty.inc' );
	require_once( '../system/mdao/Class_M_INS_SHOP.php' );
	require_once( '../system/mdao/Class_M_OTHER.php' );
	require_once( '../system/Class_FILE_CSV.php' );
	require_once( '../system/Class_ERROR.php' );
	require_once( '../system/login.inc.php' );
	require_once( '../system/aoki_m.php' );
	require_once( '../system/Class_PWD.php' );
	require_once( '../system/Class_MAIL.php' );
	
	
	
	
	Class_PWD::valid_auth(AOKI_AUTH_INS_SHOP,$login['staff_auth']);
	$docsv_import = FALSE;
	
	$csvf = Class_FILE_CSV::get_upload_file();
	
	if   ( ($login['staff_auth'] == 'G-0') || ($login['staff_auth'] == 'G-1') ) {
		$sort = $_POST["sort"] ;
	}else {
		$sort = 1 ;
	}
	$csvtype = $sort;
	$isG4 = FALSE;
	if   ($login['staff_auth'] == 'G-4') {
		$isG4 = TRUE;
		$csvtype = 2;
	}
	
	$isG5 = FALSE;
	if   ($login['staff_auth'] == 'G-5') {
		$isG5 = TRUE;
		$csvtype = 3;
	}

	if ($csvf) {
		// ロケール情報の変更
		$locale = setlocale(LC_ALL, 0);
		setlocale(LC_ALL,'ja_JP.UTF-8');
		$rowall = Class_FILE_CSV::fget_rows($csvf);
		//} elseif  ( (!empty($rowall)) && ($sort == 2) ) {
		
		if  (!empty($rowall) ) {
			if ($csvtype == 1) {
				$col_heads = array(
				'ins_shop_cd'       ,//GEOコード',       1),
				'ins_shop_name'     ,//販売店名',        1),
				'ins_co_cd'         ,//折込会社コード',  1),
				''                  ,//折込会社名',      1),
				'block_cd'          ,//ブロックコード',  1),
				''                  ,//ブロック名',      1),
				'local_cd'          ,//都道府県コード',  1),
				''                  ,//都道府県名',      1),
				'media_name'        ,//媒体名',          1),
				'delive_cd'         ,//納品先コード',    1),
				''                  ,//納品先',          1),
				'insert_conums'     ,//折込会社部数',    2),
				'area_pattern_cd'   ,//地域広告有無(コード)',      1),
				''                  ,//地域広告有無(地域新聞名)',  1),
				'area_adnums'       ,//地域広告部数',      1),
				'area_memo'         ,//地域広告備考',      1),
				''                  ,//店舗名',            1),
				'aoki_compete'      ,//AOKI/競合(コード)', 1),
				''                  ,//AOKI/競合',         1),
				'shop_away'         ,//店舗からの距離',    2),
				'home_percent'      ,//世帯普及率',        2),
				'all_amount'        ,//総需要額',          2),
				'sale_share'        ,//売上高シェア',      2),
				'stop_date'         ,//廃止日',          3),
				'memo'              ,//廃止コメント',    4),
				''                  ,//更新日時',        3),
				''                  ,//登録日時',        3),
				''                  ,//更新者',          1)
			);
		}
		
		if ($csvtype == 2) {
			$col_heads = array(
				'ins_shop_cd'       ,//GEOコード',       1),
				'ins_shop_name'     ,//販売店名',        1),
				'ins_co_cd'         ,//折込会社コード',  1),
				''                  ,//折込会社名',      1),
				'block_cd'          ,//ブロックコード',  1),
				''                  ,//ブロック名',      1),
				'local_cd'          ,//都道府県コード',  1),
				''                  ,//都道府県名',      1),
				'media_name'        ,//媒体名',          1),
				'delive_cd'         ,//納品先コード',    1),
				''                  ,//納品先',          1),
				'insert_conums'     ,//折込会社部数',    2),
				'memo'              ,//廃止コメント',    4),
				''                  ,//更新日時',        3),
				''                  ,//登録日時',        3),
				''                  ,//更新者',          1)
			);	
		}
		
		if ($csvtype == 3) {
			$col_heads = array(
				'ins_shop_cd'       ,//GEOコード',       1),
				'ins_shop_name'     ,//販売店名',        1),
				'ins_co_cd'         ,//折込会社コード',  1),
				''                  ,//折込会社名',      1),
				'block_cd'          ,//ブロックコード',  1),
				''                  ,//ブロック名',      1),
				'local_cd'          ,//都道府県コード',  1),
				''                  ,//都道府県名',      1),
				'media_name'        ,//媒体名',          1),
				'area_pattern_cd'   ,//地域広告有無(コード)',      1),
				''                  ,//地域広告有無(地域新聞名)',  1),
				'area_adnums'       ,//地域広告部数',    1),
				'area_memo'         ,//地域広告備考',    1),
				''                  ,//更新日時',        3),
				''                  ,//登録日時',        3),
				''                  ,//更新者',          1)
			);
		}
				$dt_begin = date('Y-m-d H:i:s', time());
				
				//$csvheads = array('ins_shop_cd','ins_shop_name','ins_co_cd','local_cd','media_name','delive_name','insert_conums','stop_date','memo');
				$csvheads    = array();
				$col_index   = array();
				
				$page = NULL;
				$ins = NULL;
				if ($isG4){
	 				$ins_co_del = $_SESSION['ADMIN_LOGIN']['STAFF_INS_CO_CD'] ;
				} 
				$delive_data = Class_M_OTHER::get_delive( $delive, $page,NULL,$ins_co_del );
				foreach ($delive_data as $k=>$v) {
					$delive_arr[$v["cd"]] = $v["name"];
				}
				
				$block_arr         = Class_M_OTHER::get_block_array();
				$area_pattern_arr  = Class_M_OTHER::get_pattern_array(NULL, '23' );
				$ins_co_arr        = Class_M_OTHER::get_ins_co_array();
				$local_arr         = Class_M_OTHER::get_local_array();
				
				if ($isG4){
					 $g4_ins_co_cd   = $_SESSION['ADMIN_LOGIN']['STAFF_INS_CO_CD'] ;
					 $g4_ins_co_name = $ins_co_arr[$forms["ins_co_cd"]];
				}
				
				foreach ($col_heads as $k => $v) {
					if (!empty($v)) {
						$csvheads[$k]  = $v;
						$col_index[$v] = $k;
					}
				} 
				
				//$csvheadsG4[$col_index["ins_shop_cd"]]    = "ins_shop_cd";
				//$csvheadsG4[$col_index["ins_shop_name"]]  = "ins_shop_name";
				//$csvheadsG4[$col_index["insert_conums"]]  = "insert_conums";
				//$csvheadsG4[$col_index["stop_date"]]      = "stop_date";
				//$csvheadsG4[$col_index["memo"]]           = "memo";
			
				$index_ins_co_cd       = $col_index['ins_co_cd'];      //
				$col_ins_co_cd         = $index_ins_co_cd + 1;
				
				$index_local_name      = $col_index['local_cd'];      //
				$col_local_cd          = $index_local_cd + 1;
				
				$index_block_cd        = $col_index['block_cd'];      //
				$col_block_cd          = $index_block_cd + 1;
				if (($csvtype != 3) ) {
					$index_delive_cd       = $col_index['delive_cd'];      //
					$col_delive_cd         = $index_delive_cd + 1;
				}
				if (($csvtype != 2) ) {
					$index_area_pattern_cd = $col_index['area_pattern_cd'];      //
					$col_area_pattern_cd   = $index_area_pattern_cd + 1;
				}
				if (($csvtype == 1) ) {
					$index_aoki_compete    = $col_index['aoki_compete'];      //
					$col_aoki_compete      = $index_aoki_compete + 1;
				}
				$key1 = $col_index['ins_shop_cd'];//キーです、必ず仕様します
				
				$err = new Class_ERROR("","");
				$dao = new Class_M_INS_SHOP;
				//
				$ngline      = 0;
				$error_times = 0;
				$error_stop  = IMPORT_STOP_MAX_ERROR_TIMES;
				$errtext     = array();
				$isng        = FALSE;
				$chk         = $dao->get_checks();
				
				
				$ins_co_csv_arr = array();
				if ($isG4){
					$ins_co_csv_arr[$g4_ins_co_cd] = $ins_co_arr[$g4_ins_co_cd];
				}
				$linecount = count($rowall);
				$percentold = 100;
				
	 			foreach ($rowall as $line => $row) {
	 				
					$isng = FALSE;
					$percent = intval($line/$linecount * 100)."%";
					if  ( $percent != $percentold ) {
						Class_FILE_CSV::write_msg_checking_per( $percent ) ;
					}
					$percentold = $percent;
								
					//CSV内部重複不可チェック
					foreach ($rowall as $kk=>$vv) {
						if  ($line != $kk) {
							if ($row[$key1] == $vv[$key1]){
								$col = $key1 + 1;
								$isng = TRUE;
								$ngMsg_tmp[$line][] = "{$line}行と{$kk}行の{$col}列目の値重複不可。";
								$error_times++;
								if ($error_times > $error_stop) {
									break;
								}
							}
						}
					} 
					
					if ($csvtype != 1) {
						/*
						foreach ( $csvheadsG4 as $k=>$v ) {
							$msg =  $err->check( $rowall[$line][$k], $chk[$v ] ); 
							if (!empty($msg)) {
								$isng = TRUE;
								$col  = $k+1;
								$ngMsg_tmp[$line][] = "{$line}行{$col}列目：{$msg}。";
								$error_times++;					
								if ($error_times > $error_stop) {
									break;
								}
							}
						}
						*/
						$keyvalues =   $dao->quote($row [$key1]) ;
						$where = sprintf(" {$col_heads[$key1]} = '%s'", $keyvalues );
						if ( !$dao->exits( $where ) ) {
							$isng = TRUE;
							$error_times++;
							$ngMsg_tmp[$line][] = "{$line}行：販売店コード'は存在しません。</br>";
						}	
					} else {
					
					}
					//一般チェック
					foreach ( $csvheads as $k=>$v ) {
							if ( isset($chk[$v] ) ) {
								$msg =  $err->check( $row[$k], $chk[$v] ); 
								if (!empty($msg)) {
									$isng = TRUE;
									$col  = $k+1;
									$ngMsg_tmp[$line][] = "{$line}行{$col}列目：{$msg}。";
									$error_times++;					
									if ($error_times > $error_stop) {
										break;
									}
								}
							}
						}
						
					//府県
					if ( !empty($row[$index_local_cd])){
						if (empty($local_arr[$row[$index_local_cd]])) {
							//$aaa = $row[$index_local_cd];
							$isng = TRUE;
							$error_times++;
							$ngMsg_tmp[$line][] = "{$line}行{$col_local_cd}列目：{$row[$index_local_cd]}都道府県は存在しません。</br>";
						}
					} 
					
					//ブロックコードチェック
					if ( !empty($row[$index_block_cd])){
						if (empty($block_arr[$row[$index_block_cd]])) {
							$isng = TRUE;
							$error_times++;
							$ngMsg_tmp[$line][] = "{$line}行{$col_block_cd}列目：{$row[$index_block_cd]}ブロックは存在しません。</br>";
						}
					} 
					//パターン
					if ( !empty($row[$index_area_pattern_cd])){
						if (empty($area_pattern_arr[$row[$index_area_pattern_cd]])) {
							$isng = TRUE;
							$error_times++;
							$ngMsg_tmp[$line][] = "{$line}行{$col_area_pattern_cd}列目：{$row[$index_area_pattern_cd]}地域広告は存在しません。</br>";
						}
					} else {
						if ($csvtype == 3) {
							$isng = TRUE;
							$error_times++;
							$ngMsg_tmp[$line][] = "{$line}行{$col_area_pattern_cd}列目：{$row[$index_area_pattern_cd]}地域広告は入力必須です。</br>";
						}
					}
					
					//AOKI/競合
					if ( !empty($row[$index_aoki_compete])){
						if (empty($aoki_compete_sort[$row[$index_aoki_compete]])) {
								$isng = TRUE;
								$error_times++;
								$ngMsg_tmp[$line][] = "{$line}行{$col_aoki_compete}列目：{$row[$index_aoki_compete]}AOKI/競合は存在しません。</br>";
						}
					}
				
					//納品先チェック
					if ( !empty($row[$index_delive_cd])){
						if (empty($delive_arr[$row[$index_delive_cd]])) {
								$isng = TRUE;
								$error_times++;
								$ngMsg_tmp[$line][] = "{$line}行{$col_delive_cd}列目：{$row[$index_delive_cd]}納品先は存在しません。</br>";
						}
					}
					
					//折込会社存在チェック
					if ( !empty($row[$index_ins_co_cd])){
						if ($isG4){
							if ($row[$index_ins_co_cd] != $g4_ins_co_cd ) {
								$isng = TRUE;
								$error_times++;
								$ngMsg_tmp[$line][] = "{$line}行{$col_ins_co_cd}列目：折込会社コードは存在しません。</br>";
							}
						}else {
							if (empty($ins_co_arr[$row[$index_ins_co_cd]])) {
								$isng = TRUE;
								$error_times++;
								$ngMsg_tmp[$line][] = "{$line}行{$col_ins_co_cd}列目：折込会社コードは存在しません。</br>";
							}else {
								if  ( empty($ins_co_csv_arr[$row[$index_ins_co_cd]]) ) {
									$ins_co_csv_arr[$row[$index_ins_co_cd]] = $ins_co_arr[$row[$index_ins_co_cd]];
								}
							}
						}
					}
					
					if ( $isng ) {
						++$ngline;
						$errtext[$ngline] = $row;
						if ($error_times > $error_stop) {
							break;
						}
					}
				}
				
				$dt_dbbegin = date('Y-m-d H:i:s',time());
				if ($ngline > 0) {
					$errHtml = Class_FILE_CSV::format_msg($ngMsg_tmp);
					if ($error_times > $error_stop) {
						Class_FILE_CSV::write_msg_error( $errHtml ,$error_stop );	
					
					} else {
						Class_FILE_CSV::write_msg_error( $errHtml );	
					}
				} else {
					//DBへ更新
					
					try {
						$daodb = $dao->get_db();
						$dao->begin_trans();
						$i = 0;
						$percent = "";
						$percentold = "";
						if ($csvtype == 2) {
							foreach ( $rowall as $k=>$v ) {
								$i++;
								$percent = intval($i/$linecount * 100)."%";
								if  ( $percent != $percentold ) {
									Class_FILE_CSV::write_msg_doing( $percent ) ;
								}
								$percentold = $percent;
								$values  = array();
								foreach ( $csvheads as $kk => $vv ) {
									$values[$vv] = $v[$kk];
								}
								//echo "<br>=========================".$values["ins_shop_cd"]."=========================";												
								//$values["ins_shop_cd"]   = $dao->quote($values['ins_shop_cd'] );
								//$values["ins_shop_name"] = $values['ins_shop_name'] ;
								$values["ins_co_name"]   =  $ins_co_arr[$values["ins_co_cd"]];
								$values["local_name"]    =  $local_arr[$values["local_cd"]];
								$values["block_name"]    =  $block_arr[$values["block_cd"]];
								$values["delive_name"]   =  $delive_arr[$values["delive_cd"]];
								if (!($dao->editbycol($keyvalues ,$values ,$col_heads[$key1] ))) {
										throw new Exception("minsshop_import");
								}
							}
						}elseif ($csvtype == 3) {
							foreach ( $rowall as $k=>$v ) {
								$i++;
								$percent = intval($i/$linecount * 100)."%";
								if  ( $percent != $percentold ) {
									Class_FILE_CSV::write_msg_doing( $percent ) ;
								}
								$percentold = $percent;
								$values  = array();
								foreach ( $csvheads as $kk => $vv ) {
									$values[$vv] = $v[$kk];
								}
								//echo "<br>=========================".$values["ins_shop_cd"]."=========================";												
								//$values["ins_shop_cd"]   = $dao->quote($values['ins_shop_cd'] );
								//$values["ins_shop_name"] = $values['ins_shop_name'] ;
								$values["block_name"]    =  $block_arr[$values["block_cd"]];
								$values["local_name"]    =  $local_arr[$values["local_cd"]];
								$keyvalues  = $values["ins_shop_cd"] ;
								if (!($dao->editbycol($keyvalues ,$values ,$col_heads[$key1] ))) {
										throw new Exception("minsshop_import");
								}
							}
						} else {
							
							foreach ( $rowall as $k=>$v ) {
								$i++;
								$percent = intval($i/$linecount * 100)."%";
								if  ( $percent != $percentold ) {
									Class_FILE_CSV::write_msg_doing( $percent ) ;
								}
								$percentold = $percent;
								$values  = array();
								
								foreach ( $csvheads as $kk => $vv ) {
									$values[$vv] = $v[$kk];
								}
								
								$keyvalues =  $values[$col_heads[$key1]];
								$where = sprintf(" {$col_heads[$key1]} = '%s'", $dao->quote($keyvalues) );
								
								//$values["ins_shop_cd"]   = $values['ins_shop_cd'] ;
								//$values["ins_shop_name"] = $values['ins_shop_name'] ;
								
								$values["shop_away"]     = empty($values["shop_away"]) ? '0' : $values["shop_away"];
								$values["home_percent"]  = empty($values["home_percent"]) ? '0' : $values["home_percent"];
								$values["all_amount"]    = empty($values["all_amount"]) ? '0' : $values["all_amount"];
								$values["sale_share"]    = empty($values["sale_share"]) ? '0' : $values["sale_share"];
								$values["stop_date"]     =  Class_PWD::date_to_int8 ( $values['stop_date'] );
								
								//$values["media_cd"]      =  Class_M_OTHER::do_media($values["media_name"], $daodb);
								
								$values["delive_name"]   =  $delive_arr[$values["delive_cd"]];
								$values["ins_co_name"]   =  $ins_co_arr[$values["ins_co_cd"]];
								$values["local_name"]    =  $local_arr[$values["local_cd"]];
								$values["block_name"]    =  $local_arr[$values["block_cd"]];
								
								if ( $dao->exits( $where ) ) {
									unset($values["media_name"] ); 
									if (!($dao->editbycol($keyvalues ,$values ,$col_heads[$key1] ))) {
										throw  new Exception("minsshop_import DB更新");
									}
									
								} else {
									$values["media_cd"]    =  Class_M_OTHER::do_media($values["media_name"], $daodb);
									if ( !( $dao->add($values ) ) ) {
										throw  new Exception("minsshop_import DB登録");
									}
								}
							}
						}
						$dao->commit_trans();
						$dt_end = date('Y-m-d H:i:s',time());
						
						//echo "*********************************<br>" ;
						//echo "*    ".(strtotime($dt_end) - strtotime($dt_begin))."  <br>" ;
						//echo "*********************************<br>" ;
						$mailmsg = Class_MAIL::get_insshop_csv_upd_text($ins_co_csv_arr, $login['staff_name'] );
						
						$mails  = Class_M_OTHER::get_mails();
						if (!Class_MAIL::mail_to($mailmsg, $mails)) {
							Class_FILE_CSV::write_msg_succed($linecount, "minsshop", "9");
						} else {
							Class_FILE_CSV::write_msg_succed($linecount, "minsshop");
						}
					} catch (Exception $e) {
						$dao->rollback_trans();
						Class_FILE_CSV::write_msg_error( "DB Exceptionがありました。</br>" );
					}
				} 
		//	} elseif  ( (!empty($rowall)) && ($sort == 2) ) {
				/*
				$col_heads = array(
					'ins_shop_cd'      ,//販売店コード',    1),
					'area_pattern_cd'  ,//地域広告パタンコード
					'area_adnums'      ,//地域広告部数
					'area_memo'         //地域広告備考
				);
				$dt_begin = date('Y-m-d H:i:s', time());
			
				//	$csvheads = array('ins_shop_cd','ins_shop_name','ins_co_cd','local_cd','media_name','delive_name','insert_conums','stop_date','memo');
				$csvheads    = array();
				$col_index   = array();
				
				$ins_co = Class_M_OTHER::get_ins_co_array(PLEASE_SELECT_ARR);
				
				foreach ($col_heads as $k => $v) {
					if (!empty($v)) {
						$csvheads[$k]  = $v;
						$col_index[$v] = $k;
					}
				} 
				
				$index_ins_co_cd       = $col_index['ins_co_cd'];      //
				$col_ins_co_cd         = $index_ins_co_cd + 1;
				
				$key1 = $col_index['ins_shop_cd'];//キーです、必ず仕様します
				
				$err = new Class_ERROR("","");
				$dao = new Class_M_INS_SHOP;
				
				$ngline      = 0;
				$error_times = 0;
				$error_stop  = IMPORT_STOP_MAX_ERROR_TIMES;
				$errtext     = array();
				$isng        = FALSE;
				$chk         = $dao->get_checks();
				

				$local_arr   = array();
		
				foreach ($local_arr1 as $kk =>$vv ) {
					$local_arr[$vv] = $kk;
				}
				
				$linecount = count($rowall);
				$percentold = 100;
	 			foreach ($rowall as $line => $row) {
					$isng = FALSE;
					$percent = intval($line/$linecount * 100)."%";
					if  ( $percent != $percentold ) {
						Class_FILE_CSV::write_msg_checking_per( $percent ) ;
					}
					$percentold = $percent;
								
					//CSV内部重複不可チェック
					foreach ($rowall as $kk=>$vv) {
						if  ($line != $kk) {
							if ($row[$key1] == $vv[$key1]){
								$col = $key1 + 1;
								$isng = TRUE;
								$ngMsg_tmp[$line][] = "{$line}行と{$kk}行の{$col}列目の値重複不可。";
								$error_times++;
								if ($error_times > $error_stop) {
									break;
								}
							}
						}
					} 
					
					//販売店コードは存在チェック
					$keyvalues = $row[$key1];
					$where = sprintf(" {$col_heads[$key1]} = '%s'", $dao->quote($keyvalues) );
					if ( !$dao->exits( $where ) ) {
						$col = $key1 + 1;
						$isng = TRUE;
						$error_times++;
						$ngMsg_tmp[$line][] = "{$line}行{$col}列目：販売店コードは存在しません。</br>";
					}
					
					//一般チェック
						foreach ( $csvheads as $k=>$v ) {
							if ( isset($chk[$v] ) ) {
								$msg =  $err->check( $row[$k], $chk[$v] ); 
								if (!empty($msg)) {
									$isng = TRUE;
									$col  = $k+1;
									$ngMsg_tmp[$line][] = "{$line}行{$col}列目：{$msg}。";
									$error_times++;					
									if ($error_times > $error_stop) {
										break;
									}
								}
							}
						}
						
					
					if ( $isng ) {
						++$ngline;
						$errtext[$ngline] = $row;
						if ($error_times > $error_stop) {
							break;
						}
					}
				}
				
	
				
				$dt_dbbegin = date('Y-m-d H:i:s',time());
				if ($ngline > 0) {
					$errHtml = Class_FILE_CSV::format_msg($ngMsg_tmp);
					if ($error_times > $error_stop) {
						Class_FILE_CSV::write_msg_error( $errHtml ,$error_stop );	
					
					} else {
						Class_FILE_CSV::write_msg_error( $errHtml );	
					}
				} else {
					//DBへ更新
					
					try {
						$daodb = $dao->get_db();
						$dao->begin_trans();
						$i = 0;
						$percent = "";
						$percentold = "";
						
							foreach ( $rowall as $k=>$v ) {
								$i++;
								$percent = intval($i/$linecount * 100)."%";
								if  ( $percent != $percentold ) {
									Class_FILE_CSV::write_msg_doing( $percent ) ;
								}
								$percentold = $percent;
								$values  = array();
								
								foreach ( $csvheads as $kk => $vv ) {
									$values[$vv] = $v[$kk];
								}
								
								$keyvalues =  $values[$col_heads[$key1]];
								
								//$where = sprintf(" {$col_heads[$key1]} = '%s'", $dao->quote($keyvalues) );
								
								$values["ins_shop_cd"]     = $values['ins_shop_cd'] ;
								$values["area_pattern_cd"] = empty($values['area_pattern_cd']) ? 0 :  $values['area_pattern_cd'];
								$values["area_adnums"]     = empty($values['area_adnums']) ? 0 :  $values['area_adnums'];
								$values["area_memo"]       =  $values['area_memo'];
								
								if (!($dao->editbycol($keyvalues ,$values ,$col_heads[$key1] ))) {
									throw  new Exception("minsshop_import DB更新");
								}

							}
						$dao->commit_trans();
						$dt_end = date('Y-m-d H:i:s',time());
						
						echo "*********************************<br>" ;
						echo "*    ".(strtotime($dt_end) - strtotime($dt_begin))."  <br>" ;
						echo "*********************************<br>" ;
						
						//$mailmsg = Class_MAIL::get_insshop_csv_upd_text($ins_co_csv_arr, $login['staff_name'] );
						//$mails  = Class_M_OTHER::get_mails();
						//if (!Class_MAIL::mail_to($mailmsg, $mails)) {
						//	Class_FILE_CSV::write_msg_succed($linecount, "minsshop", "9");
						//} else {
						//	Class_FILE_CSV::write_msg_succed($linecount, "minsshop");
						//}
					} catch (Exception $e) {
						$dao->rollback_trans();
						Class_FILE_CSV::write_msg_error( "DB Exceptionがありました。</br>" );
					}
				} 
				*/
			} else {
				$errHtml = "CSVファイルエラー";
				Class_FILE_CSV::write_msg_error( $errHtml );
					
			}
			
			// ロケール情報の復元
			setlocale(LC_ALL, $locale);
	
	}else {
		$errHtml = "CSVファイルエラー";
		Class_FILE_CSV::write_msg_error( $errHtml );
	}
?>
</body>
	</himl>
	